package com.yxuan.springboot.controller;

import com.yxuan.springboot.model.TestQuestions;
import com.yxuan.springboot.service.TestQuestionsService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;

/**
 * @author zchao
 * TestQuestions控制器
 * @date 2023-05-16 14:22:57
 */
@Controller
@Api(tags = "")
@RequestMapping(value = "/testquestions", method = {RequestMethod.POST, RequestMethod.GET})
public class TestQuestionsController extends BaseController<TestQuestions> {

    @Autowired
    private TestQuestionsService testQuestionsService;

//    新增题目

    @Override
    @RequestMapping(value = "/addquestion", method = RequestMethod.POST)
    public String saveT(@RequestBody TestQuestions entity) throws IOException {
            Date date = new Date();
            Timestamp timestamp = new Timestamp(date.getTime());
            entity.setCreateTime(timestamp);
            entity.setUpdateTime(timestamp);
            return super.saveT(entity);
    }


    //    删除题目
    @Override
    @RequestMapping(value = "/delquestion", method = RequestMethod.POST)
    public String delete(@RequestBody TestQuestions testQuestions) {
        return super.delete(testQuestions);
    }


//    修改题目

    @Override
    @RequestMapping(value = "/updatequestion", method = RequestMethod.POST)
    public String updT(@RequestBody TestQuestions entity) throws Exception {
        Date date = new Date();
        Timestamp timestamp = new Timestamp(date.getTime());
        entity.setUpdateTime(timestamp);
        return super.updT(entity);
    }


//    查询所有题目


//    根据类别名字查询题目


}
